package com.sk.weichat.adapter;

import android.support.annotation.Nullable;
import android.text.SpannableStringBuilder;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

import com.baidu.mapapi.search.core.PoiInfo;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.weichat.R;
import com.sk.weichat.bean.DynamicLoactionBean;
import com.sk.weichat.util.AppUtils;

import java.util.List;

/**
 * @Author: chenzl
 * @ClassName: SearchLocationListAdapter
 * @Description: java类作用描述
 * @CreateDate: 2019/10/23 20:43
 */
public class SearchLocationListAdapter extends BaseQuickAdapter<DynamicLoactionBean.LoactionResult, BaseViewHolder> {

    private String keyword;
    public SearchLocationListAdapter(@Nullable List<DynamicLoactionBean.LoactionResult> data) {
        super(R.layout.layout_search_location_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, DynamicLoactionBean.LoactionResult item) {
        helper.addOnClickListener(R.id.rt_search_location);
        TextView tv_address_title = helper.getView(R.id.tv_address_title);
        TextView tv_address_info = helper.getView(R.id.tv_address_info);
        tv_address_info.setVisibility(View.VISIBLE);
        if (item.getName().contains(keyword)){
            SpannableStringBuilder style = AppUtils.TextColorkeywordByBule(mContext,item.getName(),keyword);
            tv_address_title.setText(style);
        }else {
            tv_address_title.setText(item.getName());
        }
//        SpannableStringBuilder style1 = AppUtils.TextColorkeywordByBule(mContext,item.getAddress(),keyword);
        tv_address_info.setText(item.getAddress());
    }


    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
}
